package org.dtrd.modules.questionnaire.entity.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchiveOverview;
import org.dtrd.modules.archive.entity.po.DtrdEntRdArchivePhysical;
import org.dtrd.modules.patient.entity.po.DtrdEntRdPatient;
import org.dtrd.modules.questionnaire.entity.po.DtrdEntQuestionnaireRdReversion;

import java.util.Date;

/**
 * <p>
 * 调查问卷
 * </p>
 *
 * @author QR
 * @since 2022-02-15
 */
@Getter
@Setter
@ApiModel(value = "调查问卷详情")
public class QuestionnaireRdVersionDetail {

    private Integer dataId;

    @ApiModelProperty(value = "姓名", required = true)
    private String name;

    @ApiModelProperty(value = "患者id", required = true)
    private Integer patientId;

    @ApiModelProperty(value = "性别, 1-男, 2-女", required = true)
    private Integer sex;

    @ApiModelProperty(value = "手机号", required = true)
    private String phone;

    @ApiModelProperty(value = "糖尿病确诊情况, 1-未确诊, 2-已确诊",required = true)
    private Integer diabetesDiagnosis;

    @ApiModelProperty("糖尿病类型：1-1型糖尿病,2-2型糖尿病,3-妊娠糖尿病,4-其他类型糖尿病, 已确诊时需要填写")
    private Integer diabetesType;

    @ApiModelProperty("糖尿病确诊日期, 已确诊时需要填写, yyyy-MM-dd 格式")
    @JsonFormat(pattern = Constant.TIME_PATTERN_SDF, timezone = "GMT+8")
    private Date diabetesDiagnosisDate;

    @ApiModelProperty("糖尿病家族史")
    private Integer diabetesFamilyHistory;

    @ApiModelProperty("用药情况, 1-吃药, 2-打胰岛素, 3-吃药和打胰岛素, 4-不用药")
    private Integer drugHistory;

    @ApiModelProperty(value = "身高", required = true)
    private Float height;

    @ApiModelProperty(value = "体重", required = true)
    private Float weight;

    @ApiModelProperty(value = "腰围", required = true)
    private Float waistline;

    @ApiModelProperty(value = "C肽", required = true)
    private Float cPeptide;

    @ApiModelProperty(value = "C肽-餐后两小时", required = true)
    private Float cPeptide2h;

    @ApiModelProperty(value = "空腹血糖", required = true)
    private Float sugarFasting;

    @ApiModelProperty(value = "餐后2小时", required = true)
    private Float sugar2h;

    @ApiModelProperty(value = "2小时胰岛素", required = true)
    private Float insulin2h;

    @ApiModelProperty(value = "糖尿病并发症, 1-有, 2-无", required = true)
    private Integer diabetesComplication;

    @ApiModelProperty("并发症症状, 症状选项序号用逗号组成字符串, 并发症为有时需要填写")
    private String diabetesComplicationSymptom;

    @ApiModelProperty("并发症其他症状, 并发症为其他类型时需要填写")
    private String diabetesComplicationSymptomOther;

    @ApiModelProperty("逆转结果, 0~4, 0表示不符合, 1～4对应原型1～4种结果")
    private Integer result;

    public QuestionnaireRdVersionDetail parseFromPO(DtrdEntRdPatient patient) {
        name = patient.getPatientsName();
        patientId = patient.getDataId();
        sex = patient.getPatientsSex();
        return this;
    }

    public QuestionnaireRdVersionDetail parseFromPO(DtrdEntRdArchiveOverview overview) {
        cPeptide = overview.getCPeptide();
        cPeptide2h = overview.getCPeptide2h();
        diabetesDiagnosis = overview.getIfDiabetes();
        diabetesType = overview.getDiabetesType();
        sugarFasting = overview.getSugarFasting();
        sugar2h = overview.getSugar2h();
        insulin2h = overview.getInsulin2h();
        return this;
    }

    public QuestionnaireRdVersionDetail parseFromPO(DtrdEntRdArchivePhysical physical) {
        weight = physical.getWeight();
        height = physical.getHeight();
        waistline = physical.getWaist();
        return this;
    }

    public QuestionnaireRdVersionDetail parseFromPO(DtrdEntQuestionnaireRdReversion po) {
        dataId = po.getDataId();
        diabetesFamilyHistory = po.getDiabetesFamilyHistory();
        result = po.getResult();
        phone = po.getPhone();
        diabetesDiagnosisDate = po.getDiabetesDiagnosisDate();
        drugHistory = po.getDrugHistory();
        diabetesComplication = po.getDiabetesComplication();
        diabetesComplicationSymptom = po.getDiabetesComplicationSymptom();
        diabetesComplicationSymptomOther = po.getDiabetesComplicationSymptomOther();
        return this;
    }
}
